﻿
#if WPF
using System;
using System.Windows.Media; 
#endif

public static class ColorExtendtions
{
#if WPF
        public static int ToArgb(this System.Windows.Media.Color color)
        {
            byte[] bytes = new byte[] { color.A, color.R, color.G, color.B };
            return BitConverter.ToInt32(bytes, 0);
        }
        public static Color FromArgb(this System.Windows.Media.Color color, int colorValue)
        {
            byte[] bytes = BitConverter.GetBytes(colorValue);
            if (bytes.Length != 4)
            {
                throw new Exception(Inaction.Resource.Properties.Resources.IntValueCannotChangeToColor);
            }
#if WPF
            return Color.FromScRgb(bytes[0], bytes[1], bytes[2], bytes[3]);
#else 
            return Color.FromArgb(bytes[0], bytes[1], bytes[2], bytes[3]);
#endif
        }
#endif
}